#include<bits/stdc++.h>
using namespace std;
//open long long remember
#define ll long long
long long T,n,a[200020],col[200020],ansmax;
void check(long long x)
{
    if(x>n)
    {
        long long pred=0,pblue=0,ans=0;
        for(int i=1;i<=n;i++)
        {
            if(col[i]==1)
            {
                if(a[i]==a[pred]) ans+=a[i];
                pred=i;
            }
            else{
                if(a[i]==a[pblue]) ans+=a[i];
                pblue=i;
            }
        }
        ansmax=max(ans,ansmax);
        return;
    }
    col[x]=1;
    check(x+1);
    col[x]=2;
    check(x+1);
    return;
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        ansmax=0;
        check(1);
        cout<<ansmax<<endl;
    }
    return 0;
}
